import Vue from "vue";
import VueRouter from "vue-router";
import Login from '@/views/Login/Main.vue';
import Home from '@/views/Home/Main.vue';
import bizRouters from "./routres"

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/system/staff",
  },
  {
    path: '/login',
    name: 'Login',
    meta: {
      title: '登录',
    },
    component: Login,
  },
  {
    path: '/',
    name: 'Home',
    meta: {
      title: '首页',
    },
    component: Home,
    children:bizRouters
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});
router.beforeEach(beforeEachAction);



function beforeEachAction(to, from, next) {
  const token =true
  if(token){
    console.log(12312)
  }else{
    if (to.name !== 'Login')  next({ name: 'Login' })
  }
  
 next()

}




export default router;
